package day1004;

/**
 * @Author:galaxy_yan
 * @Date: 2022/10/5
 * @Time: 20:26
 * @Description
 * https://leetcode.cn/problems/remove-element/
 */
public class RemoveElement {
    public static int removeElement(int[] nums, int val) {
        int low=0;
        for (int i = 0; i <nums.length; i++) {
            if(nums[i] != val){
                int tmp=nums[i];
                nums[i]=nums[low];
                nums[low]=tmp;
                low++;
            }
        }
        return low;
    }

    public static void main(String[] args) {
        int[] nums = {1};
        int val = 1;
        System.out.println(removeElement(nums,val));
        for (int i:
             nums) {
            System.out.println(i);
        }
    }
}
